/**
 * Title: AppGrideViewAdapter.java
 * Description:
 * Copyright: Copyright (c) 2008
 * Company:深圳彩讯科技有限公司
 * Author 罗旭东 (hi@luoxudong.com)
 * Date 2014-1-14 下午5:48:05
 * Version 1.0
 */
package com.luoxudong.phonenumber.ui.adapters;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.luoxudong.phonenumber.R;
import com.luoxudong.phonenumber.ui.adapters.vo.AppItem;

/** 
 * ClassName: AppGrideViewAdapter
 * Description:TODO(这里用一句话描述这个类的作用)
 * Create by 罗旭东
 * Date 2014-1-14 下午5:48:05
 */
public class AppGrideViewAdapter extends AbsBaseAdapter<AppItem>{

	public AppGrideViewAdapter(Context context, List<AppItem> list) {
		super(context, list);
	}

	@Override
	protected View getItemView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder = null;
		
		if (convertView == null)
		{
			convertView = inflater.inflate(R.layout.app_list_item_layout, null);
			
			viewHolder = new ViewHolder();
			viewHolder.iconImageView = (ImageView)convertView.findViewById(R.id.iv_app_logo);
			viewHolder.appNameTextView = (TextView)convertView.findViewById(R.id.tv_app_name);
			
			convertView.setTag(viewHolder);
		}
		else 
		{
			viewHolder = (ViewHolder)convertView.getTag();
		}
		
		AppItem appItem = getItem(position);
		
		if (appItem != null)
		{
			viewHolder.iconImageView.setImageResource(appItem.getAppIconResId());
			viewHolder.appNameTextView.setText(appItem.getAppName());
		}
		return convertView;
	}
	
	class ViewHolder
	{
		public ImageView iconImageView = null;
		public TextView appNameTextView = null;
	}

}
